<template>
	<view>
		<view class="middle">
			<view class="left">
				<view >
					<text class="yticon  icon-tuandui"></text>
				</view>
				<view class="right">
					<view class="right1">成功邀请</view>
					<view >
						<text class="right2">{{user.COUNT}}</text>
						<text class="right3">人</text>
					</view>
				</view>
			</view>
			<view class="left">
				<text class="yticon  icon-shouhoutuikuan"></text>
				<view class="right">
					<view class="right1">累计奖励</view>
					<view >
						<text class="right2">{{user.SPPOINT}}</text> 
						<text class="right3">{{user.NAME}}</text>
					</view>
				</view>
			</view>
		</view>
		
		<view class="un-inviteDetail">
			<view class="un-inviteDetail-tou">奖励明细</view>
			<!-- <view v-for="(item,index) in dataList" :key="index" class="un-inviteDetail-item"> -->
			<view  class="un-inviteDetail-item" v-for="(item,index) in inviteList" :key="index">
				<view class="un-inviteDetail-image">
					<image v-if="item.AVATOR" class="portrait" :src='img+item.AVATOR' mode="aspectFill"></image>
					<image v-else class="portrait" src='/static/missing-face.png'></image>
				</view>
				<view class="un-inviteDetail-T">
					<text class="clamp un-inviteDetail-T1">{{item.NAME}}</text>
					<text class="clamp un-inviteDetail-T2">{{item.PHONE}}</text>
				</view>
				<view class="un-inviteDetail-TT">
					<view >
						<text class="un-inviteDetail-T2">时间 ：{{item.CREATEDATE}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				inviteList:[],
				user:{},
				img:'',
			}
		},
		onLoad() {
			this.img = getApp().globalData.imageAddress;
			this.loadData()
			uni.startPullDownRefresh();
		},
		onPullDownRefresh() {
			console.log('refresh');
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			async loadData(){
				
				this.$http.post("/user/queryInviteDetail",{
					SIGNATURE : uni.getStorageSync("SIGNATURE"),
					TOKEN : uni.getStorageSync("userInfo").TOKEN,
				}).then((res)=>{
					console.log("*********",res);
					if(res.statusCode == 200 && res.data.STATE === '0'){
						this.user=res.data.OBJECT;
						this.inviteList = res.data.OBJECT.INVITE;
						this.inviteList.map(item=>{
							item.PHONE=item.PHONE.substring(0,3)+"****"+item.PHONE.substring(7,11)
							item.CREATEDATE=item.CREATEDATE.substring(0,10)
							return item;
						})
					}else if(res.data.STATE === "907" && res.statusCode === 200){
						//token已经失效  重新登录
						uni.removeStorageSync('userInfo')
						uni.showModal({
							content: '请重新登录',
							success: (res)=>{
								if(res.confirm){
									uni.reLaunch({
										url:'/pages/public/login1'
									})
								}else if(res.cancel) {
									
								}
							},
						})
					}else if(res.data.STATE === "906" && res.statusCode === 200){
						//正常退出失效
						//token已经失效  重新登录
						uni.removeStorageSync('userInfo')
						uni.reLaunch({
							url:'/pages/public/login1'
						})
						
					}else if(res.data.STATE === "905" && res.statusCode === 200){
						//别处登录失效
						uni.removeStorageSync('userInfo')
						uni.showModal({
							content: '已在别处登录',
							success: (res)=>{
								if(res.confirm){
									uni.reLaunch({
										url:'/pages/public/login1'
									})
								}else if(res.cancel) {
									uni.reLaunch({
										url:'/pages/public/login1'
									})
								}
							},
						})
					}else{
						uni.showToast({
							title:res.data.MSG,
							icon:'none'
						})
					}
				}).catch((err)=>{
					console.log('request fail',err);
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #F5F5F5;
	}
	.middle{
		display: flex;
		background-color: #fff;
		margin-bottom: 20upx;
		border: 1upx solid #f2f2f2;
		.left{
			display: flex;
			margin: 30upx;
			margin-left: 60upx;
			padding-right: 50upx;
			.yticon{
				color: #D0D1FD;
				font-size: 60upx;
				padding-right: 30upx;
				padding-top: 10upx;
			}
			.right1{
				font-size: 28upx;
				color: #666666;
			}
			.right2{
				font-size: 20upx;
				color: #F04844;
			}
			.right3{
				font-size: 20upx;
				color: #666666;
				margin-left: 10upx;
			}
		} 
		
	}
	.un-inviteDetail{
		border: 1upx solid #f2f2f2;
		padding: 40upx;
		background-color: #fff;
		.un-inviteDetail-tou{
			font-size: 28upx;
			color: #666666;
			margin-bottom: 40upx;
		}
		.un-inviteDetail-item{
			position: relative;
			display: flex;
			border-bottom: #f2f2f2 1upx solid;
			align-items: center;
			padding: 20upx 0upx;
			.portrait{
				width: 90upx;
				height: 90upx;
				border:5upx solid #fff;
				border-radius: 50%;
			}
			.un-inviteDetail-T{
				font-size: 25upx;
				color: #666666;
				margin: 0upx 70upx 0upx 20upx;
				line-height: 45upx;
				.un-inviteDetail-T1{
					font-size: 28upx;
				}
				.un-inviteDetail-T2{
					color: #999999;
				}
			}
			.un-inviteDetail-TT{
				position: absolute;
				top: 70upx;
				left: 400upx;
				font-size: 25upx;
				color: #666666;
				line-height: 45upx;
				.un-inviteDetail-T2{
					color: #999999;
				}
			}
		}
		
		
	}
	
	
</style>
